From 69f3c56296800ab0283a35a599c0bdd0e00443b4 Mon Sep 17 00:00:00 2001 From: "vhanquez@kneesa.uk.xensource.com" Date: Tue, 24 Jan 2006 10:52:52 +0000 Subject: [PATCH] fixup reallocation to "twice the size + 1", instead of "3 times the size". max *= 2 + 1 <==> max *= 3 Signed-off-by: Vincent Hanquez --- tools/xenstore/utils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/xenstore/utils.c b/tools/xenstore/utils.c index 1bf8606b40..f8bf989c22 100644 --- a/tools/xenstore/utils.c +++ b/tools/xenstore/utils.c @@ -99,8 +99,10 @@ void *grab_file(const char *filename, unsigned long *size) *size = 0; while ((ret = read(fd, buffer + *size, max - *size)) > 0) { *size += ret; - if (*size == max) - buffer = realloc(buffer, max *= 2 + 1); + if (*size == max) { + max *= 2; + buffer = realloc(buffer, max + 1); + } } if (ret < 0) { free(buffer); -- 2.30.2